from selenium.webdriver.support.wait import WebDriverWait
from selenium.webdriver.common.by import By
from selenium.webdriver.support import expected_conditions as EC
import time


class UserLoginPage:

    def __init__(self, driver):
        self.driver = driver

    def login_page(self, username, password):
        self.driver.find_element(By.ID, "username").send_keys(username)
        self.driver.find_element(By.NAME, "password").send_keys(password)
        self.driver.find_element(By.TAG_NAME, "button").click()


    def login_success_get_massage(self):
        return self.driver.find_element(By.XPATH, "/html/body/div/div/aside/div[1]/a").text


    def login_name_error_get_massage(self):
        return self.driver.find_element(By.XPATH, "/html/body/div/div/div/form/div[1]/span[1]").text


    def login_pwd_error_get_massage(self):
        return self.driver.find_element(By.XPATH, "/html/body/div/div/div/form/div[2]/span[1]").text
